package com.hang.mapstruct;

import com.hang.entity.TbFile;
import com.hang.model.dto.request.FileUploadDTO;
import com.hang.model.vo.FileInfoVO;
import org.mapstruct.Mapper;

import java.util.LinkedList;
import java.util.List;

@Mapper(componentModel = "spring")
public interface FileMapStruct {
    TbFile FileUploadDTOToTbFile(FileUploadDTO fileUploadDTO);

    default List<FileInfoVO> fileListToFileInfoVOList(List<TbFile> fileList){
        List<FileInfoVO> fileInfoVOList = new LinkedList<>();
        fileList.forEach(
                file ->{
                    fileInfoVOList.add(fileToFileInfoVO(file));
                }
        );

        return fileInfoVOList;
    }

    FileInfoVO fileToFileInfoVO(TbFile file);
}
